package com.eunion.core.common;

import java.util.HashMap;
import java.util.Map;

/**
 * ajax返回的json.
 * 
 * 
 * @version 2015-5-30
 */
public class AjaxJsonVo {

    private short code = WebCommon.CODE_ERROR;

    private String msg = "出错了.";

    private Map<String, Object> objs = new HashMap<String, Object>();

    public AjaxJsonVo() {

    }

    public AjaxJsonVo addMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxJsonVo addCode(int code) {
        this.code = (short) code;
        if (code == 0) {
            this.msg = "";
        }
        return this;
    }

    public AjaxJsonVo addCodeByFlag(boolean flag) {
        if (flag) {
            this.code = WebCommon.CODE_SUCCESS;
            this.msg = "";
        }
        return this;
    }

    public AjaxJsonVo addObjs(int code) {
        this.code = (short) code;
        if (code == 0) {
            this.msg = "";
        }
        return this;
    }

    public short getCode() {
        return code;
    }

    public void setCode(short code) {
        this.code = code;
    }

    public Map<String, Object> getObjs() {
        return objs;
    }

    public void setObjs(Map<String, Object> objs) {
        this.objs = objs;
    }

    public void addObjs(Map<String, Object> obj) {
        this.objs.putAll(obj);
    }

    public void addObj(String key, Object value) {
        this.objs.put(key, value);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

}
